var GraceJS = require("../../Grace.JS/grace.js");
import {
    apiServer
} from '../../common.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id: 0,
        detail:"",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var that = this;
        that.setData({
            id: options.id
        }, function(){
            that.getDetail();
        })
    },
    getDetail: function () {
        var that = this;
        wx.showLoading({
            title: 'Loading...',
        })
        GraceJS.get(
            apiServer + 'resume.News/codeDetail', {
                id: that.data.id
            }, {},
            function (res) {
                if (res.code == 0) {
                    that.setData({
                        detail: res.data,
                    })
                    GraceJS.setNavBar({
                        title: res.data.title
                    });

                    wx.hideLoading()
                } else {
                    GraceJS.msg(res.message)
                }
            }
        )
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        return {
            title: this.data.detail.title,
            path: '/pages/code-detail/index?id='+this.data.id,
        }
    },

    // 分享朋友圈
    onShareTimeline: function () {
        return {
            title: this.data.detail.title,
            query: '/pages/code-detail/index?id='+this.data.id,
        }
    }
})